package com.nbsaas.boot.project.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import com.nbsaas.boot.jpa.data.entity.User;
import com.nbsaas.boot.rest.filter.Operator;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Data;

import java.util.Date;


@ComposeView
@CreateByUser
@Data
@FormAnnotation(title = "项目计时管理", model = "项目计时")
@Entity
@Table(name = "nb_project_time")
public class ProjectTime extends AbstractEntity {


    @SearchItem(label = "项目名称", name = "project", key = "project.id", type = InputType.select, operator = Operator.eq, classType = Long.class)
    @FormField(title = "项目名称", sortNum = "1", grid = true, width = "200", type = InputType.select, option = "project", required = true, col = 22)
    @FieldConvert
    @FieldName
    @ManyToOne(fetch = FetchType.LAZY)
    private Project project;


    @FormField(title = "用时", sortNum = "1", grid = true, required = true, col = 22)
    private Integer usedTime;


    @FormField(title = "填写人", sortNum = "3", grid = true, ignore = true)
    @FieldName
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private User creator;


    @FormField(title = "记录日期", sortNum = "4", width = "1500", grid = true, type = InputType.date, sort = true, col = 22)
    private Date recordDate;


    @FormField(title = "内容", sortNum = "100", type = InputType.textarea, col = 22)
    private String note;

}
